<html>
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>

<label for="inputText">Name:</label>
<input id="inputText" type="text"/>
<span id="value"></span>

<button id="change-button">change value</button>
<script>
  var inputData = '';
  var inputText = document.querySelector('#inputText');
  inputText.addEventListener('input', function(event){
    inputData = event.target.value;
    document.querySelector('#value').innerText = inputData;
  });

  var button = document.querySelector('#change-button');
  button.addEventListener('click', function (event) {
    inputText.value = 'change';
    inputData = 'change';
  });

</script>
</body>
</html>
